
$(function() {	
	Tip.emp('员工');
});

var Connection = {
	dialog_add_: function (url, title, xy) {
		var result = Common.result();
		$('#dialog_add').dialog('option', 'buttons', {	
			"关闭": function() { 
				$(this).dialog("close");
			},			
			
			"添加": function() {				
				if (!confirm("确认是否添加？")) {
					return false;
				}
				
				var form = $("#form_add")[0];
	
				var body = { };
				body.emp = form.emp.value;
				body.date = form.date.value;
				
				body.ip = form.ip.value;
				
				body.name = form.name.value;
				body.content = form.content.value;
				
				// alert($.toJSON(body));
				
				$(this).dialog("close");
	
				$.post('wifi.php?do=Connection.addPost', body, function(data) {
					$(result).html(data);
				});
			}
		});
	
		dialog_add(url, title, xy);
	},

	popup: function (e, p2, id) {
		$.cookie('id_', id);

		p2 = query(p2);
		$.cookie('p2', p2);

		var a1 = ['黑名单', 'url', 'Connection.dialog_black_', '650x400'];
		var a2 = ['查看信息', 'url', 'Common.dialog_view_', '650x400'];
		// var a3 = ['复制信息', 'url', 'Connection.dialog_copy_', '650x400'];
		
		var c1 = 'wifi.php?do=Connection.black&id=' + id;
		var c2 = 'wifi.php?do=Connection.view&id=' + id;
		
		var c3 = 'wifi.php?do=Connection.copy&id=' + id;
		
		var s = c1 + ", " + c2;

		popup(e, [a1, a2], s);
	},

	dialog_black_: function (url, title, xy) {
		var result = Common.result();
		$('#dialog_add').dialog('option', 'buttons', {			
			"关闭": function() {
				$(this).dialog("close");
			},
	
			"添加黑名单": function() {
				if (!confirm("确认是否提交？")) {
					return false;
				}
	
				var form = $("#form_add")[0];
	
				var body = {};
				body.id = form.id.value;
				
				body.emp = form.emp.value;
				body.date = form.date.value;
				
				body.username = form.username.value;
				body.mac = form.mac.value;
				
				body.name = form.name.value;
				body.content = form.content.value;
	
				$(this).dialog("close");
	
				var url = 'wifi.php?do=Black.addPost';
				var p2 = $.cookie('p2');
				if (p2 != null) {
					url += p2;
				}
	
				$.post(url, body, function(data) {
					alert("添加成功！");
					// $(result).html(data);
				});
			}
		});
	
		dialog_add(url, title, xy);
	},
	
	dialog_copy_: function (url, title, xy) {
		var result = Common.result();
		
		$('#dialog_add').dialog('option', 'buttons', {			
			"关闭": function() {
				$(this).dialog("close");
			},
	
			"复制": function() {
				if (!confirm("确认是否提交？")) {
					return false;
				}
	
				var form = $("#form_add")[0];
	
				var body = {};
				body.emp = form.emp.value;
				body.date = form.date.value;
				
				body.ip = form.ip.value;
				
				body.name = form.name.value;
				body.content = form.content.value;
	
				$(this).dialog("close");
	
				var url = 'wifi.php?do=Connection.addPost';
				var p2 = $.cookie('p2');
				if (p2 != null) {
					url += p2;
				}
	
				$.post(url, body, function(data) {
					$(result).html(data);
				});
			}
		});
	
		dialog_add(url, title, xy);
	},
	
	popup_all: function (e, p2) {
		p2 = query(p2);
		$.cookie('p2', p2);

		var c1 = 'wifi.php?do=Connection.delete' + p2;
		var c9 = 'wifi.php?do=Connection.xls' + p2;
			
		var a1 = ['删除信息', 'url', 'Common.list_delete'];
		var a9 = ['导出Excel', 'url', 'jswin', '1024x768'];

		var s = c1 + ", " + c9;

		return popup(e, [a1, a9], s);
	}
};
